package com.google.code.p.ivans;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.List;

import javax.ejb.EJB;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cafe.ejb.WaiterService;
import cafe.ejb.myexceptions.EntityNotFoundException;
import cafe.jpa.Waiter;


public class WaitersServlet extends HttpServlet {	 
   
	private static final long serialVersionUID = -2466926194499516942L;
	
	@EJB 
	private WaiterService waiterSI;
 
    public WaitersServlet() {
    	
    }
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {		
			
		List<Waiter> waiters = null;
		
		try {
			waiters = waiterSI.getAllWaiters();
		} catch (SQLException e) {			
			e.printStackTrace();
		} catch (EntityNotFoundException e) {			
			e.printStackTrace();
		}		
			
		request.setAttribute("waiters", waiters);		
		
		RequestDispatcher requestDispatcher = request.getRequestDispatcher("waiters.jsp");
		requestDispatcher.forward(request, response);		
	}
}
